package com.message.queue.rabbit.topic;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhangbo on 2020/7/17.
 */
@RestController
public class SendTopicMessageController {

    @Autowired
    private RabbitTemplate rabbitTemplate;


    @GetMapping("/send1/{message}")
    public Object sendTopicMessage1(@PathVariable(value = "message") String message) {
        rabbitTemplate.convertAndSend("topicExchange", TopicRabbitConfig.MAN, message);
        return "ok";
    }


    @GetMapping("/send2/{message}")
    public Object sendTopicMessage2(@PathVariable(value = "message") String message) {
        rabbitTemplate.convertAndSend("topicExchange", TopicRabbitConfig.WOMAN, message);
        return "ok";
    }
}
